package com.L.yygh.hosp.controller;

import com.L.yygh.common.result.Result;
import com.L.yygh.hosp.service.HospitalService;
import com.L.yygh.model.hosp.Hospital;
import com.L.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "医院相关信息操作")
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    //医院列表（条件查询分页-条件封装=》VO类型封装）
    @ApiOperation("查询医院列表信息接口")
    @GetMapping("/list/{currentPage}/{limitPage}")
    public Result listHosp(@PathVariable Integer currentPage,
                           @PathVariable Integer limitPage,
                           HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pageModel = hospitalService.selectHsopPage(currentPage,limitPage,hospitalQueryVo);
        return Result.ok(pageModel);
    }

    //更新医院的上线状态
    @ApiOperation("更新医院的上线状态")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable("id") String id,
                                   @PathVariable("status") Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }

    //医院详细信息
    @ApiOperation("医院详细信息")
    @GetMapping("/showHospDetail/{id}")
    public Result showHospDetail(@PathVariable("id") String id){
        Map<String,Object> hospital = hospitalService.getHospById(id);
        return Result.ok(hospital);
    }
}
